package com.practice.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.practice.J2E.constant.NumGlobalConstant;
import com.practice.enums.DashboardCardEnum;
import com.practice.response.ResponseR;
import com.practice.service.DashboardService;
import com.practice.service.UserService;
import com.practice.vo.dashboard.CardVo;
import com.practice.vo.dashboard.ListCardParam;
import com.practice.vo.dashboard.ListCardVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DashboardServiceImpl implements DashboardService {

    @Resource
    private UserService userService;

    @Override
    public ResponseR<ListCardVo> listCard(ListCardParam param) {

        // 用户数量
        CardVo userCardVo = CardVo.of(DashboardCardEnum.USER_NUM, userService.getUserNum());

        // 菜单数量
        CardVo menuCardVo = CardVo.of(DashboardCardEnum.MENU_NUM, NumGlobalConstant.THREE);

        // 天选
        CardVo avatarCardVo = CardVo.of(DashboardCardEnum.AVATAR, userService.getAvatar());


        List<CardVo> cardVoList = CollUtil.newArrayList(userCardVo,menuCardVo,avatarCardVo);
        return ResponseR.ok(ListCardVo.of(cardVoList));
    }
}
